﻿using System.Collections.Generic;

namespace Needle.Bus.Engine.Factories
{
    /// <summary>
    /// Interface for creating named instances.
    /// It is up to the implementor to decide wether to return
    /// a cached instance or create a new instance on every Create invocation.
    /// </summary>
    public interface IFactory<T>
    {
        /// <summary>
        /// Creates the named instance. throws ArgumentException if 
        /// id is not known.
        /// </summary>
        T Create(string id);
        /// <summary>
        /// Creates all known instances. Can throw a NotSupportedException
        /// </summary>
        IList<T> CreateAll();
    }
}
